package com.shrct.businessprocess.project;

import com.google.common.base.Objects;
import com.uniquesoft.uidl.validation.Validates;
import edu.fudan.mylang.pf.BaseDataType;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

public class NumberRange extends BaseDataType {
  public NumberRange() {
    super();
  }
  
  private Double fromValue;
  
  public Double getFromValue() {
    return this.fromValue;
  }
  
  public NumberRange setFromValue(final Double fromValue) {
    this.fromValue = fromValue;
    return this;			
    
  }
  
  private Double toValue;
  
  public Double getToValue() {
    return this.toValue;
  }
  
  public NumberRange setToValue(final Double toValue) {
    this.toValue = toValue;
    return this;			
    
  }
  
  public Boolean canMerge(final NumberRange otherRange) {
    boolean _equals = Objects.equal(this.toValue, otherRange.fromValue);
    return Boolean.valueOf(_equals);
  }
  
  public NumberRange merge(final NumberRange otherRange) {
    NumberRange _xblockexpression = null;
    {
      Boolean _canMerge = this.canMerge(otherRange);
      Validates.Assert((_canMerge).booleanValue(), "\u8303\u56F4\u8BBE\u5B9A\u4E0D\u5408\u6CD5");
      NumberRange _numberRange = new NumberRange();
      final Procedure1<NumberRange> _function = new Procedure1<NumberRange>() {
          public void apply(final NumberRange it) {
            it.fromValue = NumberRange.this.fromValue;
            it.toValue = otherRange.toValue;
          }
        };
      NumberRange _doubleArrow = ObjectExtensions.<NumberRange>operator_doubleArrow(_numberRange, _function);
      _xblockexpression = (_doubleArrow);
    }
    return _xblockexpression;
  }
  
  public static NumberRange create() {
    return new NumberRange();
    
    
  }
}
